﻿using System;
using System.IO;
using System.Reflection;
using UnityEngine;

namespace Framework.Extension
{
    public static class TypeExtension
    {
        public static PropertyInfo GetPropertyRecursion(this Type type, string name)
        {
            PropertyInfo info = null;
            while (info == null && type != null)
            {
                
                info = type.GetProperty(name);
                Debug.Log("ceshishushu" + info + type);
                type = type.BaseType;
                
            }

            return info;
        }

        public static FieldInfo GetFileRecursion(this Type type, string name)
        {
            FieldInfo info = null;
            while (info == null && type != null)
            {
                info = type.GetField(name);
                 
                type = type.BaseType;
            }

            return info;
        }
    }
}